package com.zonski.jbots.desktop.editer;

import com.zonski.jbots.desktop.client.RoomRenderer;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Chris Glover
 * Date: Oct 27, 2003
 * Time: 9:36:36 AM
 * To change this template use Options | File Templates.
 * <p>
 * A canvas for editing
 */
public class EditerCanvas extends JComponent
{
    private JBotsEditerContext context;
    private RoomRenderer roomRenderer;

    public EditerCanvas()
    {
    }

    public void setContext(JBotsEditerContext context)
    {
        this.context = context;
    }

    public void setRoomRenderer(RoomRenderer roomRenderer)
    {
        this.roomRenderer = roomRenderer;
    }

    public void paint(Graphics g)
    {
        g.clearRect(0, 0, this.getWidth(), this.getHeight());
        if(context.getRoom() != null)
        {
            roomRenderer.render(g, context.getRoom());
        }
    }
}
